<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: 'App',
  components:{

  },
  created() {
      //添加一个响应拦截器
    axios.interceptors.response.use(
      function(res) {
        //在这里对返回的数据进行处理
        if (res.data.statusCode == 401) {
          //登出
          localStorage.clear();
          delete axios.defaults.headers.common["Authorization"];
          this.$router.push("/loading");
          return;
        }
        return res;
      },
    )
  }
}
</script>

<style></style>
